<?php
/**
This script handles the destruction of user sessions. Note that the destruction
of user sessions cannot be handled by the log-out code since it is written in
javascript (see: loggedinbox.js).

This script watches out for a GET variable login_catch value of 1. When that value
is passed to any page, this script destroys the current user session.
*/
// TODO: Ayusin ang script na ito.
include("login_constants.php");

function logout(){
	$dirpath = explode(DIRECTORY_SEPARATOR, getcwd());
	if($dirpath[count($dirpath) - 1] == "useraccount"){
		echo "<script type='text/javascript' language='javascript'>window.location = '../index.php'</script>";
	}
	
	unset($_SESSION["logged_in"]);
	session_destroy();
}

if($_GET["login_catch"] != Null){
	switch($_GET["login_catch"]){
		
		case LOGOUT_MODE:
			logout();
			break;
		default:
			//echo "<script type='text/javascript' language='javascript' src='boilerplate/js/account_area.js'></script>";
	}
}

if(isset($_SESSION["login_failure"])){
	echo "<div class='error'>Invalid Log-in ID and/or Password. Please try again.</div><br />\n";
	session_destroy();
}
?>